/**
 * 
 */
package edu.cmu.cs.webapp.ioms.ui.providers.order;

import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.Viewer;

import edu.cmu.cs.webapp.ioms.dao.DataAccessException;
import edu.cmu.cs.webapp.ioms.dao.impl.OrderDAOImpl;
import edu.cmu.cs.webapp.ioms.models.PurchaseOrder;
import edu.cmu.cs.webapp.ioms.test.DummieDataGenerator;

/**
 * @author Christian
 * 
 */
public class OrdersTableViewerContentProvider implements
		IStructuredContentProvider {

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java
	 * .lang.Object)
	 */
	public Object[] getElements(Object parentElement) {
		if (parentElement instanceof PurchaseOrder[]) {
			return (PurchaseOrder[]) parentElement;

		}
		//
		// if (parentElement instanceof DummieDataGenerator) {
		// return ((DummieDataGenerator)parentElement).getOrders();
		// }

		if (parentElement instanceof PurchaseOrder) {
			return ((PurchaseOrder) parentElement).getItems().toArray();
		}

		return null;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.jface.viewers.IContentProvider#dispose()
	 */
	public void dispose() {

	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface
	 * .viewers.Viewer, java.lang.Object, java.lang.Object)
	 */
	public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
		// TODO Auto-generated method stub

	}

}
